package org.one.stone.soup.grfxML.connector;

import org.one.stone.soup.grfxML.DataString;
import org.one.stone.soup.mjdb.data.field.Field;
import org.one.stone.soup.mjdb.data.field.FloatField;
import org.one.stone.soup.mjdb.data.field.IntField;
import org.one.stone.soup.mjdb.data.field.LockException;

public class grfxMLConnector {
public static void connect(Field source,DataString target,String attribute,int index) {

 try{
	target.setValue( source.toString(),source );
 }catch(LockException le){} //dummy catch
}
public static void connect(Field source,Field target,String attribute,int index) {
	return;
}
public static void connect(Field source,FloatField target,String attribute,int index) {

 try{
	if(source instanceof FloatField)
	{
		target.setValue( ((IntField)source).getValue(),source );
	}
	else if(source instanceof IntField)
	{
		target.setValue( (float)((FloatField)source).getValue(),source );
	}
}catch(LockException le){} //dummy catch
}
public static void connect(Field source,IntField target,String attribute,int index) {

 try{
	if(source instanceof IntField)
	{
		target.setValue( ((IntField)source).getValue(),source );
	}
	else if(source instanceof FloatField)
	{
		target.setValue( (int)((FloatField)source).getValue(),source );
	}
 }catch(LockException le){} //dummy catch
}
}
